#pragma once
#include "sensorutility_global.h"
#include <glm/glm.hpp>
#include <opencv/cv.h>

class SENSORUTILITY_EXPORT SensorIntrinsic
{
public:
	SensorIntrinsic ();
	~SensorIntrinsic ();

	float fx () const;
	float fy () const;
	float centerX () const;
	float centerY () const;
	float fw () const;
	float fh () const;
	float k1 () const;
	float k2 () const;
	float k3 () const;
	float p1 () const;
	float p2 () const;
	const cv::Matx33f& matrixCvMat () const;
	const cv::Vec< float, 5 >& distCoeffsCvMat () const;
	const glm::mat3 &getMatrix () const;
	const float *getDistCeoffs () const;
	void set (const glm::mat3 matrix, const float distCeoffs[5]);
	glm::vec2 project (glm::vec3 p) const;
	glm::vec3 unproject (glm::vec3 p) const;
	void readFrom (const QString& file);
	void writeTo (const QString& file) const;
	QString getFilename () const;
private:
	QString _filename;
	glm::vec2 _frameSize;
	glm::mat3 _matrix;
	float _distCeoffs[5];
	cv::Matx33f _matrixCvMat;
	cv::Vec< float, 5 > _distCoeffsCvMat;

	void _updateCvMats ();
};